# Maintainer: Christian Rebischke <chris.rebischke@archlinux.org>

pkgname=plumber
pkgver=2.5.2
pkgrel=1
pkgdesc="Swiss army knife CLI tool for interacting with Kafka, RabbitMQ and other messaging systems."
arch=('loong64' 'x86_64')
url="https://github.com/batchcorp/plumber"
license=('Apache')
depends=('glibc')
makedepends=('go' 'git')
source=("${pkgname}-${pkgver}.tar.gz::https://github.com/batchcorp/${pkgname}/archive/v${pkgver}.tar.gz")
sha512sums=('2a65beefcb3b01dbb7b9b1ad044627e9084103431966adb344b2276ac97e813a3d9194b52faa1cca24787ed3066877c8cb56e38861e3369be9e0855b198f7cbf')
b2sums=('517004a40b018e5fd8e37aef7216ac48d2ba58261607ae12b21fce66d153975c0033b44d40e370a5356888e36f9fbda27f7faf0f6fa3f7a9d9dfc59953daeca6')

build(){
  cd "${pkgname}-${pkgver}"
  export CGO_CPPFLAGS="${CPPFLAGS}"
  export CGO_CFLAGS="${CFLAGS}"
  export CGO_CXXFLAGS="${CXXFLAGS}"
  export CGO_LDFLAGS="${LDFLAGS}"
  export GOFLAGS="-buildmode=pie -ldflags=-linkmode=external -trimpath -mod=readonly -modcacherw"
  go build -o plumber-bin .
}

check() {
  cd "${pkgname}-${pkgver}"
  go test ./...
}

package() {
  cd "${pkgname}-${pkgver}"
  install -Dm755 plumber-bin "${pkgdir}/usr/bin/${pkgname}"
}

